package com.hz.monitoring.module.hardware.dal.mysql.monitoring_data;

import java.util.*;

import com.hz.monitoring.framework.common.pojo.PageResult;
import com.hz.monitoring.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hz.monitoring.framework.mybatis.core.mapper.BaseMapperX;
import com.hz.monitoring.module.hardware.dal.dataobject.monitoring_data.MonitoringDataDO;
import org.apache.ibatis.annotations.Mapper;
import com.hz.monitoring.module.hardware.controller.admin.monitoring_data.vo.*;

/**
 * 监测数据 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MonitoringDataMapper extends BaseMapperX<MonitoringDataDO> {

    default PageResult<MonitoringDataDO> selectPage(MonitoringDataPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MonitoringDataDO>()
                .eqIfPresent(MonitoringDataDO::getSensorTenantResourceId, reqVO.getSensorTenantResourceId())
                .eqIfPresent(MonitoringDataDO::getMcuTenantResourceId, reqVO.getMcuTenantResourceId())
                .eqIfPresent(MonitoringDataDO::getMcuModel, reqVO.getMcuModel())
                .likeIfPresent(MonitoringDataDO::getSensorName, reqVO.getSensorName())
                .eqIfPresent(MonitoringDataDO::getSensorModel, reqVO.getSensorModel())
                .betweenIfPresent(MonitoringDataDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(MonitoringDataDO::getId));
    }

    default List<MonitoringDataDO> selectList(MonitoringDataExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MonitoringDataDO>()
                .eqIfPresent(MonitoringDataDO::getSensorTenantResourceId, reqVO.getSensorTenantResourceId())
                .eqIfPresent(MonitoringDataDO::getMcuTenantResourceId, reqVO.getMcuTenantResourceId())
                .eqIfPresent(MonitoringDataDO::getMcuModel, reqVO.getMcuModel())
                .likeIfPresent(MonitoringDataDO::getSensorName, reqVO.getSensorName())
                .eqIfPresent(MonitoringDataDO::getSensorModel, reqVO.getSensorModel())
                .betweenIfPresent(MonitoringDataDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(MonitoringDataDO::getId));
    }

}
